<?php

/**
 * This is the model class for table "xyh_activity_link_vote_a".
 *
 * The followings are the available columns in table 'xyh_activity_link_vote_a':
 * @property string $id
 * @property string $activity_id
 * @property string $vote_q_id
 * @property string $a_content
 * @property string $sort
 * @property string $select_count
 */
class ActivityLinkVoteA extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ActivityLinkVoteA the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'xyh_activity_link_vote_a';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('activity_id, vote_q_id, sort', 'length', 'max'=>10),
			array('a_content', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, activity_id, vote_q_id, a_content, sort', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    
                     'ActivityLinkVoteQ' => array(self::BELONGS_TO, 'ActivityLinkVoteQ', 'vote_q_id'),
                  
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'activity_id' => 'Activity',
			'vote_q_id' => 'Vote Q',
			'a_content' => 'A Content',
			'sort' => 'Sort',
			
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search($activity_id='')
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;
                
                $criteria->addCondition("activity_id=$activity_id");
		$criteria->compare('id',$this->id,true);
		$criteria->compare('activity_id',$this->activity_id,true);
		$criteria->compare('vote_q_id',$this->vote_q_id,true);
		$criteria->compare('a_content',$this->a_content,true);
		$criteria->compare('sort',$this->sort,true);
		

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}